<ui:composition template="/WEB-INF/templates/showcase.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:o="http://omnifaces.org/ui"
>
	<ui:define name="description">
		<p>
			Unlike native JSF validation error messages, in a bean validation message by default the label
			of the component where a validation constraint violation originated from can not be displayed
			in the middle of a message.		
		</p>
		<p>
			Using the <code>javax.faces.validator.BeanValidator.MESSAGE</code> bundle key such label can
			be put in front or behind the message, but that's it.
		</p>
		<p>
			With the <em>JsfLabelMessageInterpolator</em> a label can appear in the middle of a message, by
			using the special placeholder <code>{jsf.label}</code> in bean validation messages.
		</p>
		
	</ui:define>

	<ui:define name="demo">
	
		<p>
			Enter more than 2 resp. 3 characters in the input fields below and press submit to trigger 
			a validation error. Note how the field's label appears in the message, which originates from
			<code>ValidationMessages.properties</code>.
		</p>
		
		<h:form>
			<h:messages />
			
			<h:panelGrid columns="2">
				<o:outputLabel for="foo" value="Foo" />
				<h:inputText id="foo" value="#{validateConstraintsBean.constrainedEntity.foo}" />

				<o:outputLabel for="bar" value="Bar" />
				<h:inputText id="bar" value="#{validateConstraintsBean.constrainedEntity.bar}" />
				
				<h:commandButton value="submit">
					<f:ajax execute="@form" render="@form" />
				</h:commandButton>
				
			</h:panelGrid>
			
		</h:form>
	</ui:define>
</ui:composition>